package comman.duke.display 
{
	import comman.duke.*;
	import comman.duke.display.AnimsData;
	import flash.display.Bitmap;
	/**
	 * ...
	 * @author jerry.d
	 */
	public class BitmapClipFactory 
	{
		private var resMap:Object = {};
		public function BitmapClipFactory() 
		{
			
		}
		
		public function loadAnim():void{
			ResourceLoader.Instance.load([{url:'./resource/anims.json', type:ResourceLoader.TYPE_TEXT}, {url:'./resource/anims.png', type:ResourceLoader.TYPE_IMAGE}], 
			this.onAnimLoaded);
		}
		
		public function onAnimLoaded():void{
			var data:Object = JSON.parse(String(ResourceLoader.Instance.getAsset('./resource/anims.json')));
			var texture:Bitmap = ResourceLoader.Instance.getAsset('./resource/anims.png') as Bitmap;
			this.resMap['anims'] = new comman.duke.display.AnimsData('anims', texture.bitmapData, data);
		}
		
		public function getBitmapClipData(key:String):comman.duke.display.AnimsData{
			return this.resMap[key];
		}
		
		private static var _instance:BitmapClipFactory;
		public static function get Instance():BitmapClipFactory{
			if ( BitmapClipFactory._instance == null ){
				BitmapClipFactory._instance = new BitmapClipFactory();
			}
			return BitmapClipFactory._instance;
		}
	}

}